package cn.seaboot.admin.security.auth;

import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Configuration;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.SessionTrackingMode;
import java.util.Collections;

/**
 * 如果自定义登录流程，很可能会报错，提示url中间不允许出现 “;”。
 * 因为系统老是自动拼接上jsessionid，这时候增加一个配置类即可。
 * <p>
 * 禁用jsessionid
 *
 * @author Mr.css
 * @version 2022-01-06 18:34
 */
@Configuration
public class DisabledJsessionidInitializer implements ServletContextInitializer {

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        servletContext.setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE));
    }
}
